using MicroMsg.Resource.@string;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Phone.Shell;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace MicroMsg.UI.Page
{
	public class SnsPostSlidePreView : BasePage
	{
		public delegate void RotateImgEvent(List<int> nAngleList);
		private List<int> angleList = new List<int>();
		private bool bIsFirstLoad = true;
		private int mIndex;
		private ApplicationBar mBar;
		private ApplicationBarIconButton RotateBtn;
		private ApplicationBarMenuItem DelItem;
		internal Grid LayoutRoot;
		internal PostPanoramaContainer mPanoramaSlideCtrl;
		private bool _contentLoaded;
		public event SnsPostSlidePreView.RotateImgEvent mRotateImgEvent;
		public SnsPostSlidePreView()
		{
			this.InitializeComponent();
			base.add_Loaded(new RoutedEventHandler(this.SnsPostSlidePreView_Loaded));
		}
		private void SnsPostSlidePreView_Loaded(object sender, RoutedEventArgs e)
		{
			if (this.bIsFirstLoad)
			{
				base.set_ApplicationBar(this.GetAppBar());
				for (int i = 0; i < this.mPanoramaSlideCtrl.postMainPage.picPathList.get_Count(); i++)
				{
					this.angleList.Add(this.mPanoramaSlideCtrl.postMainPage.picPathList.get_Item(i).nAngle);
				}
				this.bIsFirstLoad = false;
			}
		}
		protected override void OnPageIn(object[] object_0)
		{
			if (object_0 != null && object_0.Length >= 2)
			{
				this.mIndex = (int)object_0[0];
				this.mRotateImgEvent = (object_0[1] as SnsPostSlidePreView.RotateImgEvent);
				this.mPanoramaSlideCtrl.InitData(this.mIndex);
				return;
			}
		}
		protected override void OnPageOut()
		{
			if (this.mRotateImgEvent != null)
			{
				this.mRotateImgEvent(this.angleList);
			}
		}
		private ApplicationBar GetAppBar()
		{
			this.mBar = new ApplicationBar();
			this.mBar.set_IsMenuEnabled(true);
			this.mBar.set_IsVisible(true);
			if (this.mBar != null)
			{
				this.mBar.set_BackgroundColor(((SolidColorBrush)R.theme.COMMON_APPBAR_BK_BRUSH).get_Color());
				this.mBar.set_ForegroundColor(((SolidColorBrush)R.theme.COMMON_APPBAR_FG_BRUSH).get_Color());
			}
			this.RotateBtn = new ApplicationBarIconButton(new Uri("/Resource/Img/CommonUse/icon_rotate.png", 2));
			this.RotateBtn.set_Text(strings.Filter_Rotate_Image);
			this.RotateBtn.add_Click(new EventHandler(this.RotateBtn_Click));
			this.mBar.get_Buttons().Add(this.RotateBtn);
			this.DelItem = new ApplicationBarMenuItem();
			this.DelItem.set_Text(strings.COM_Del);
			this.DelItem.add_Click(new EventHandler(this.DelItem_Click));
			this.mBar.get_MenuItems().Add(this.DelItem);
			return this.mBar;
		}
		private void RotateBtn_Click(object sender, EventArgs e)
		{
			List<int> list;
			int nowIndex;
			(list = this.angleList).set_Item(nowIndex = this.mPanoramaSlideCtrl.nowIndex, list.get_Item(nowIndex) + 90);
			List<int> list2;
			int nowIndex2;
			(list2 = this.angleList).set_Item(nowIndex2 = this.mPanoramaSlideCtrl.nowIndex, list2.get_Item(nowIndex2) % 360);
			Duration duration = new Duration(TimeSpan.FromMilliseconds(500.0));
			Storyboard storyboard = new Storyboard();
			storyboard.set_Duration(duration);
			DoubleAnimation doubleAnimation = new DoubleAnimation();
			doubleAnimation.set_Duration(duration);
			storyboard.get_Children().Add(doubleAnimation);
			Storyboard.SetTarget(doubleAnimation, this.mPanoramaSlideCtrl.CurrentImgCtrl.get_RenderTransform());
			Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Angle", new object[0]));
			doubleAnimation.set_To(new double?((double)this.angleList.get_Item(this.mPanoramaSlideCtrl.nowIndex)));
			doubleAnimation.set_From(new double?((double)(this.angleList.get_Item(this.mPanoramaSlideCtrl.nowIndex) - 90)));
			storyboard.Begin();
		}
		private void DelItem_Click(object sender, EventArgs e)
		{
			this.mPanoramaSlideCtrl.RemoveUISnsMediaIndex();
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/Sns/Common/UI/UploadAndPost/SnsPostSlidePreView.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.mPanoramaSlideCtrl = (PostPanoramaContainer)base.FindName("mPanoramaSlideCtrl");
		}
	}
}
